package eu.dominicum.ft.pd;

import eu.dominicum.ft.pd.mao.AssociateRiderMAO;
import eu.dominicum.ft.pd.mao.MakeTeamMemberMAO;

/**
 * A Team Member.
 *
 * @author Harry Klerks
 * @since 2013M1
 */
public class TeamMember extends PersistentDomainObject {

    /**
     * The Team Member's yersey number.
     */
    private Integer yerseyNumber;
    /**
     * The {@link Team} object that the Team Member is part of.
     */
    private Team team;

    /**
     * The {@link ProfessionalCyclist} object that plays the role of rider.
     */
    private ProfessionalCyclist rider;

    /**
     * Protected constructor to satisfy JPA.
     */
    protected TeamMember() {

    }

    /**
     * .
     *
     * @return Integer
     */
    public final Integer getYerseyNumber() {
        return yerseyNumber;
    }

    /**
     * .
     *
     * @return Team
     */
    public final Team getTeam() {
        return team;
    }

    /**
     * Makes a TeamMember object.
     *
     * @param makeTeamMemberMAO -
     * @return TeamMember
     */
    static TeamMember make(final MakeTeamMemberMAO makeTeamMemberMAO) {

        TeamMember newTeamMember = new TeamMember();

        newTeamMember.yerseyNumber = makeTeamMemberMAO.getYerseyNumber();
        newTeamMember.team = makeTeamMemberMAO.getTeam();

        return newTeamMember;
    }

    /**
     * .
     *
     * @return ProfessionalCyclist
     */
    public final ProfessionalCyclist getRider() {
        return rider;
    }

    /**
     * Associate a given {@link ProfessionalCyclist} object with this team member.
     *
     * @param associateRiderMAO -
     */
    public final void associateRider(final AssociateRiderMAO associateRiderMAO) {

        this.rider = associateRiderMAO.getRider();
    }
}
